<template>
  <div>
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <div>
      评测对象: {{userName}}
      </div>
      <el-table v-loading="loading" :data="resultList" >
        <el-table-column label="序号" align="center" prop="evalutionResultId" width="60"/>
        <el-table-column label="评测工号" align="center" prop="userName" />
        <el-table-column label="评测姓名" align="center" prop="nickName" />
        <el-table-column label="评测分数" align="center" prop="score" width="60"/>
        <el-table-column label="评测时间" align="center" prop="createTime" width="140"/>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listResult } from "@/api/evalution/result";
export default {
  name: "Result",
  data() {
    return {
      userName: null,
      // 遮罩层
      loading: true,
      // 评测分数表格数据
      resultList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        participatorId: null,
        recordType: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  methods: {
    /** 查询评测分数列表 */
    getList(userName, participatorId, recordType) {
      if(recordType=='leader'){
        this.title = '领导测评';
      }else if(recordType=='colleague'){
        this.title = '同事测评';
      }else{
        this.title = '学生测评';
      }
      this.userName = userName;
      this.open = true;
      this.queryParams = {
        participatorId: participatorId,
        recordType: recordType,
      };
      this.loading = true;
      listResult(this.queryParams).then(response => {
        this.resultList = response.rows;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.queryParams = null;
    },
  }
};
</script>
